import Sale from "./sale.js"
import Shopcar from "./shopcar.js"
const template = `
    <div>
        <Sale 
            v-for="(item,i) in getSaleList" :key="item.id"
            :data="item"
            v-show="i>=(current-1)*4 && i<current*4"
            :order="order"
            @input="changeOrder"
        />
        
        <Shopcar 
            :orderPrice="order.price" 
            :orderNum="order.num" 
            :orderList="order.list"/>
    </div>
`
export default {
    template,
    props:{
        current:{
            type:Number,
            default:1
        },
        saleList:{
            type:Array,
            default:[]
        }
    },
    data(){
        return{
            order:{
                list:[],
                price:0,
                num:0
            }
        }
    },
    methods:{
        changeOrder(data){
            this.order = data;
            console.log(this.order.list);
        }
    },
    computed:{
        getSaleList(){
            return this.saleList
        }
    },
    components: {
        Sale,
        Shopcar
    }
}